package com.objecteffects.template.web.action;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Rusty Wright
 */
public enum PostType {
    POSTS,
    DRAFTS,
    QUEUE;

    private static final Map<String, PostType> STRING_TO_ENUM = new HashMap<>();

    private final String lcName;

    PostType() {
        this.lcName = this.name().toLowerCase();
    }

    static {
        for (final PostType pt : values()) {
            PostType.STRING_TO_ENUM.put(pt.toString(), pt);
        }
    }

    /*
     * Returns TumblrMethod for string, or null if string is invalid.
     */
    public static PostType fromString(final String name) {
        return PostType.STRING_TO_ENUM.get(name);
    }

    @Override
    public String toString() {
        return this.lcName;
    }

    public String getLcName() {
        return this.lcName;
    }
}
